import { Component, OnInit, ViewChild, Input } from '@angular/core';
import { HttpService } from 'lbf';
import { SFComponent } from '@delon/form';


@Component({
  selector: 'lb-yjszx',
  templateUrl: './lb_yjszx.html',
})
export class YjszxComponent implements OnInit {
  _dad017 = 0;
  yjsSchema = {
    properties: {
      DAD017: {
        type: 'string',
        title: '事项主键',
        ui: {
          hidden: true,
        },
      },
      DAE001: {
        type: 'string',
        title: '事项选择',
        enum: [],
        ui: { widget: 'checkbox', span: 24 ,
        checkAll: true,
        checkAllText: '全选',
        size: 'large'},
      },
    },
    required: ['DAE001'],
    ui: {
      spanLabelFixed: 80,
      grid: {
        gutter: 20,
        span: 24,
      },
    },
  };

  yjsformdata: {};
  
  @ViewChild('yjs', { static: false }) yjs: SFComponent;
  @Input() set DAD017(value:number) {
    this._dad017 = value
     this.getSx();    
  }
  get DAD017() {
    return this._dad017
  }

  @Input() set FormData(value:any) {
    this.yjsformdata = value
  }
  get FormData() {
    return this.yjs.value;
  }

  getSx() {
    this.lbservice
      .lbservice('YJS_QUERY', { para: { DAD017: this._dad017 } })
      .then(res => {
        this.yjsSchema = {
          properties: {
            DAD017: {
              type: 'string',
              title: '事项主键',
              ui: {
                hidden: true,
              },
            },
            DAE001: {
              type: 'string',
              title: '事项选择',
              enum: res.message.list,
              
              ui: { 
                widget: 'checkbox', 
                span: 24,
                checkAll: true,
                checkAllText: '全选',
                size: 'large'
              },
            },
          },
          required: ['DAE001'],
          ui: {
            spanLabelFixed: 80,
            grid: {
              gutter: 20,
              span: 24,
            },
          },
        };
      });
    // return this.sfs;
  }

  
  constructor(
    private lbservice: HttpService,
    
  ) {
    
  }

  ngOnInit() {
    
  }


}